package com.leyou.order.web;

import com.leyou.order.service.OrderService;
import com.leyou.order.vo.WxNotifyResult;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author 虎哥
 */
@RestController
@RequestMapping("pay")
public class PayController {

    private final OrderService orderService;

    public PayController(OrderService orderService) {
        this.orderService = orderService;
    }

    @PostMapping(value = "/wx/notify", produces = MediaType.APPLICATION_XML_VALUE)
    public WxNotifyResult handleNotify(@RequestBody Map<String, String> data) {
        // 处理回调
        orderService.handleNotify(data);
        return WxNotifyResult.ok();
    }
}
